<?php
/*
 *author:Yangligao
 *Date:2013-9-29
 */
require '../../Config.php';
$flag = $_GET['flag'];

if($flag == 'display'){
	
	$cpModel = new JoinCpModel();
	$cpData = $cpModel->joincp_select("cp_id,cp_name");
	
	$smarty->assign('cpData',$cpData);
	$smarty->display('Admin/ProM/proinsert.html');
}else if($flag == 'proinsert'){
	unset($_POST['x']);
	unset($_POST['y']);
	$_POST['food_addtime'] = time();
	$_POST['food_producttime'] = strtotime($_POST['year1']."-".$_POST['month1']."-".$_POST['day1']);
	$_POST['food_enddate'] = strtotime($_POST['year2']."-".$_POST['month2']."-".$_POST['day2']);
	
	//去掉表单中的year  month   day
	
	unset($_POST['year1']);
	unset($_POST['year2']);
	unset($_POST['month1']);
	unset($_POST['month2']);
	unset($_POST['day1']);
	unset($_POST['day2']);
	
	//准备好图片
	
	$upload = new Upload();
	
	$picPath = $upload->savePic("../Upload/foodPic/");
	
	$_POST['food_pic'] = $picPath;
	
	$foodModel = new FoodModel();
	$res = $foodModel->food_insert($_POST);
	
	if($res){
		jump('操作成功！', $_SERVER['HTTP_REFERER']);
	}else{
		alertInfo('操作失败！！', $_SERVER['HTTP_REFERER']);
	}	
	
}
?>
